﻿using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;

namespace TaoNiuOA.Models
{
    /// <summary>
    /// 绩效
    /// 由工作部分和考勤部分组成
    /// </summary>
    public class Performance
    {
        [Key]
        public int PerformanceID { get; set; }

        [Display(Name = "考核名称")]
        public string Title { get; set; }

        [Display(Name = "考核用户")]
        public int UserID { get; set; }

        [Display(Name = "考核月份")]
        public string Month { get; set; }

        [Display(Name = "应得绩效")]
        public double TotalPoint { get; set; }

        [Display(Name = "主管评分")]
        public double AdminPoint { get; set; }

        [Display(Name = "实得绩效")]
        public double PayPoint { get; set; }

        [Display(Name = "状态")]
        public int Status { get; set; }

        [Display(Name = "最后更新")]
        public DateTime? LastUpdate { get; set; }

        //[Display(Name = "备注")]
        //public string Remark { get; set; }

        /// <summary>
        /// 获取该绩效的用户信息
        /// </summary>
        /// <returns></returns>
        public User GetUser()
        {
            var db = new TaoNiuOA.Models.DbEntity();
            var user = db.Users.SingleOrDefault(n => n.UserID == this.UserID);
            if (user == null)
                user = new User();
            return user;
        }

    }
}